<!DOCTYPE html>
<html lang="en">
<head>
    <script src="js/jquery-3.3.1.js"></script>
    <meta charset="UTF-8">
    <style>
        .user-container {
            display: flex;
            align-items: center;
        }

        .user-avatar {
            width: 100px;
            height: 100px;
            border: solid 0.05rem #34b3de;
            border-radius: 50%;
            overflow: hidden;
            background-size: cover;
            background-position: 50%;
            margin-right: 20px;
            margin-left: 600px;
        }
        .user-avatar {
            width: 100px;
            height: 100px;
            overflow: hidden;
        }

        #image {
            width: 100%;
            height: 100%;
            object-fit: cover; /* 使用cover值保持原始宽高比并填充容器 */
        }
        .user-info {
            display: flex;
            flex-direction: column;
        }

        .user-info h2 {
            margin-top: 0;
        }



        .user-actions .button {
            width: 400px;
            display: block;
            margin: 25px 550px;
            padding: 10px 20px;
            font-size: 25px;
            text-decoration: none;
            text-align: center;
            border: 2px solid #333;
            border-radius: 5px;
            transition: background-color 0.3s ease, color 0.3s ease;
            color: #333;

        }
        /*.user-actions .button {*/
        /*    height: 60px;*/
        /*    margin: 5px 0;*/
        /*    color: white;*/
        /*    font-size: 18px;*/
        /*    font-weight: bold;*/
        /*    transition: background-color 0.3s, font-size 0.3s;*/
        /*}*/

        .user-actions .button:hover {
            background-color: #333;
            color: #fff;
            /*font-size: 20px;*/
        }
    </style>
</head>
<body>
<div class="user-container">
    <div class="user-avatar">
        <img id="image" src="" alt="User Avatar">
    </div>
    <div class="user-info">
        <h2 id="username">

        </h2>
        <p id="num">

        </p>
    </div>
</div>

<div class="user-actions">
    <button class="button" onclick="changeAvatar()">修改头像</button>
    <button class="button" onclick="changeNickName()">修改账号</button>
    <button class="button" onclick="changePassword()">修改密码</button>
    <button class="button" onclick="createPost()">发布文章</button>
    <button class="button" onclick="editPost()">编辑文章</button>
    <button class="button" onclick="showRecycleBin()">回收站</button>
    <button class="button" onclick="returnFirstPage()">返回首页</button>

</div>

<script>
    $(function () {
        //查询用户名名字
        $.get("user/findOneByCode", {}, function (data) {
            var username = data.username;
            // console.log(data);
            $("#username").html(username);
        });
        $.get("user/findArticleNumByCode",{},function (data){
            // console.log(data);
            var num =  "发布文章数量:" + data;
            $("#num").html(num);
        });

        //查询用户头像
        $.get("user/findImage",{},function(data){
            var image = document.getElementById("image");
            image.src = data.image;
        });
    });
    $(function (){

    });
    function changeAvatar() {
        // 处理修改头像逻辑
        location.href = "updateImage.jsp";
    }

    function changeNickName() {
        // 处理修改昵称逻辑
        location.href = "changeNickName.html"
    }

    function changePassword() {
        // 处理修改密码逻辑
        location.href = "changePassword.html";
    }

    function createPost() {
        // 处理发布文章逻辑
        location.href = "publishArticle.html";
    }


    function editPost() {
        // 处理编辑文章逻辑
        location.href = "user/pageQuery"
    }

    function showRecycleBin() {
        // 处理显示回收站逻辑
        location.href = "user/findArticleFromRecycle"

    }
    function returnFirstPage() {
        location.href = "index.html";
    }
</script>
</body>
</html>